package day1216

type CQueue struct {
	stack1 []int
	stack2 []int
}

func Constructor() CQueue {
	return CQueue{stack1: []int{}, stack2: []int{}}
}

func (cq *CQueue) AppendTail(value int) {
	cq.stack1 = append(cq.stack1, value)
}

func (cq *CQueue) DeleteHead() int {
	if len(cq.stack2) == 0 {
		for len(cq.stack1) > 0 {
			remove := cq.stack1[len(cq.stack1)-1]
			cq.stack1 = cq.stack1[:len(cq.stack1)-1]
			cq.stack2 = append(cq.stack2, remove)
		}
	}
	if len(cq.stack2) > 0 {
		remove := cq.stack2[len(cq.stack2)-1]
		cq.stack2 = cq.stack2[:len(cq.stack2)-1]
		return remove
	}
	return -1
}

/**
 * Your CQueue object will be instantiated and called as such:
 * obj := Constructor();
 * obj.AppendTail(value);
 * param_2 := obj.DeleteHead();
 */
